package qdu.rgzb23.notification;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;

public class Targetact extends Activity{
	int colors[]={Color.RED,Color.BLUE,Color.CYAN,Color.YELLOW,Color.GREEN};

	BroadcastReceiver br;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ly_targetact);
		Log.i("mytag","target act create...");

		br = new BroadcastReceiver() {
			@Override
			public void onReceive(Context context, Intent intent) {
				int re_color = intent.getIntExtra("make_color",-1);
				findViewById(R.id.ll_id).setBackgroundColor(re_color);
			}
		};
		IntentFilter ifilter = new IntentFilter();

		ifilter.addAction("color_cast");

		registerReceiver(br,ifilter);
	}

	@Override
	protected void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
		Log.i("mytag","[targetact on start]");
		int temp = getIntent().getIntExtra("msg",-1);
        Log.i("mytag", "test val:" + temp);
		if(temp != -1)
			findViewById(R.id.ll_id).setBackgroundColor(colors[temp]);


	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		unregisterReceiver(br);
	}
}
